package io.renren.modules.labon.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.user.entity.UserinfoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.labon.entity.LableonlineEntity;
import io.renren.modules.labon.service.LableonlineService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-04 13:12:30
 */
@RestController
@RequestMapping("labon/lableonline")
public class LableonlineController {
    @Autowired
    private LableonlineService lableonlineService;


    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("labon:lableonline:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = lableonlineService.queryPage(params);
        // 分页
//        int pageIndex = Integer.parseInt(String.valueOf(params.get("page")));
//        int pageSize = Integer.parseInt(String.valueOf(params.get("limit")));
//        String id = String.valueOf(1);
//        Page<LableonlineEntity> page = new Page<>(pageIndex,pageSize);
//
//        // 通过调用自定义dao层实现
//        lableonlineService.selectByWork(id,page);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{lableNo}")
    @RequiresPermissions("labon:lableonline:info")
    public R info(@PathVariable("lableNo") Integer lableNo){
		LableonlineEntity lableonline = lableonlineService.getById(lableNo);

        return R.ok().put("lableonline", lableonline);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("labon:lableonline:save")
    public R save(@RequestBody LableonlineEntity lableonline){
		lableonlineService.save(lableonline);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("labon:lableonline:update")
    public R update(@RequestBody LableonlineEntity lableonline){
		lableonlineService.updateById(lableonline);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("labon:lableonline:delete")
    public R delete(@RequestBody Integer[] lableNos){
		lableonlineService.removeByIds(Arrays.asList(lableNos));

        return R.ok();
    }

}
